<?php


namespace App\Http\Controllers\Admin;


use App\Model\Mention;
use App\Tool\Json;
use Illuminate\Support\Facades\Cache;

class MentionController extends AuthCheckController
{

    function saveMention(){

        $id=request()->input('id');

        $post=request()->input();

        Mention::updateOrCreate(['id'=>$id],[
            'mention_start'=> $post['mention_start'],
            'mention_end'=>$post['mention_end']
        ]);

        return Json::code(1,'success');


    }


    function getList(){

        $list=Mention::get();


        return Json::code(1,'success',$list);

    }

    function save(){


        $post=request()->input();

        Cache::put('mention:timeout',$post['timeout']);


        return Json::code(1,'success');

    }


    function getItem(){


        $data=[];


        $data['timeout']=Cache::get('mention:timeout','21:00');


        return Json::code(1,'success',$data);


    }


    function deleteMention(){

        $id=request()->input('id');

        $id=(int)$id;

        Mention::destroy($id);


        return Json::code(1,'success');

    }


}
